package cn.thr.ymcc.service.impl;

import cn.thr.ymcc.domain.KillActivity;
import cn.thr.ymcc.mapper.KillActivityMapper;
import cn.thr.ymcc.service.IKillActivityService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.text.SimpleDateFormat;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author thr
 * @since 2023-03-14
 */
@Service
public class KillActivityServiceImpl extends ServiceImpl<KillActivityMapper, KillActivity> implements IKillActivityService {
    @Transactional
    @Override
    public boolean save(KillActivity entity) {
        //日期格式
        SimpleDateFormat sdf = new SimpleDateFormat("MM-dd");
        //组装日期格式
        String timeStr = sdf.format(entity.getBeginTime())+"至"+sdf.format(entity.getEndTime());
        //把日期格式添加到数据库
        entity.setTimeStr(timeStr);
        return super.save(entity);
    }
}
